﻿@{
    Layout = null;
    ViewData["Title"] = "Index";
}
<script src="~/js/vue.js"></script>
<script src="~/js/axios.js"></script>
<script src="~/element-ui/lib/index.js"></script>
<link rel="stylesheet" href="~/element-ui/lib/theme-chalk/index.css" />
<div id="app">
    <el-form :model="ruleForm" label-width="100px" class="demo-ruleForm">
        <el-col :span="5">
            <el-form-item label="职位分类">
                <el-input v-model="human_major_kind_name" readonly></el-input>
            </el-form-item>
        </el-col>
        <el-col :span="5">
            <el-form-item label="职位名称">
                <el-input v-model="human_major_name" readonly></el-input>
            </el-form-item>
        </el-col>
        <el-col :span="5">
            <el-form-item label="招聘类型">
                <el-select v-model="engage_type" placeholder="请选择招聘类型">
                    <el-option label="校园招聘" value="校园招聘"></el-option>
                    <el-option label="社会招聘" value="社会招聘"></el-option>
                </el-select>
            </el-form-item>
        </el-col>
        <el-col :span="5">
            <el-form-item label="姓名">
                <el-input v-model="human_name"></el-input>
            </el-form-item>
        </el-col>
        <el-col :span="5">
            <el-form-item label="身份证">
                <el-input v-model="human_idcard" v-on:blur="getAge()"></el-input>
            </el-form-item>
        </el-col>
        <el-col :span="5">
            <el-form-item label="性别">
                <el-input v-model="human_sex" readonly></el-input>
            </el-form-item>
        </el-col>
        <el-col :span="5">
            <el-form-item label="Email">
                <el-input v-model="human_email"></el-input>
            </el-form-item>
        </el-col>
        <el-col :span="5">
            <el-form-item label="电话">
                <el-input v-model="human_telephone"></el-input>
            </el-form-item>
        </el-col>
        <el-col :span="5">
            <el-form-item label="家庭电话">
                <el-input v-model="human_homephone"></el-input>
            </el-form-item>
        </el-col>
        <el-col :span="5">
            <el-form-item label="手机">
                <el-input v-model="human_mobilephone"></el-input>
            </el-form-item>
        </el-col>
        <el-col :span="5">
            <el-form-item label="住址">
                <el-cascader v-model="human_address"
                             :options="options1"
                             v-on:change="handleChange"></el-cascader>
            </el-form-item>
        </el-col>
        <el-col :span="5">
            <el-form-item label="邮编" prop="yb">
                <el-input v-model="human_postcode"></el-input>
            </el-form-item>
        </el-col>
        <el-col :span="5">
            <el-form-item label="国籍">
                <el-select v-model="human_nationality" placeholder="请选择国籍" v-on:change="GuoJi()">
                    <el-option v-for="item in guoJi"
                               :key="item.pbc_id"
                               :lable="item.attribute_name"
                               :value="item.attribute_name">
                    </el-option>
                </el-select>
            </el-form-item>
        </el-col>
        <el-col :span="5">
            <el-form-item label="出生地" prop="csd">
                <template slot="label">
                    出生地
                </template>
                <el-cascader v-model="human_birthplace"
                             :options="options2"
                             v-on:change="handleChange1"></el-cascader>
            </el-form-item>
        </el-col>
        <el-col :span="5">
            <el-form-item label="生日">
                <el-input v-model="human_birthday" readonly></el-input>
            </el-form-item>
        </el-col>
        <el-col :span="5">
            <el-form-item label="民族" prop="mz">
                <el-select v-model="human_race" placeholder="请选择民族" v-on:change="MinZu()">
                    <el-option v-for="item in minZu"
                               :key="item.pbc_id"
                               :lable="item.attribute_name"
                               :value="item.attribute_name">
                    </el-option>
                </el-select>
            </el-form-item>
        </el-col>
        <el-col :span="5">
            <el-form-item label="宗教信仰" prop="zjxy">
                <el-select v-model="human_religion" placeholder="请选择宗教信仰" v-on:change="ZongJiao()">
                    <el-option v-for="item in zongJiao"
                               :key="item.pbc_id"
                               :lable="item.attribute_name"
                               :value="item.attribute_name">
                    </el-option>
                </el-select>
            </el-form-item>
        </el-col>
        <el-col :span="5">
            <el-form-item label="政治面貌" prop="zzmm">
                <el-select v-model="human_party" placeholder="请选择政治面貌" v-on:change="ZhenZhiMianMao()">
                    <el-option v-for="item in zhenZhiMianMao"
                               :key="item.pbc_id"
                               :lable="item.attribute_name"
                               :value="item.attribute_name">
                    </el-option>
                </el-select>
            </el-form-item>
        </el-col>
        <el-col :span="5">
            <el-form-item label="年龄">
                <el-input v-model="human_age" readonly="readonly"></el-input>
            </el-form-item>
        </el-col>
        <el-col :span="5">
            <el-form-item label="毕业院校" prop="byyx">
                <el-select v-model="human_college" placeholder="请选择">
                    <el-option v-for="item in options"
                               :key="item.human_college"
                               :label="item.label"
                               :value="item.human_college">
                    </el-option>
                </el-select>
            </el-form-item>
        </el-col>
        <el-col :span="5">
            <el-form-item label="学历" prop="xl">
                <el-select v-model="human_educated_degree" placeholder="请选择学历" v-on:change="XueLi()">
                    <el-option v-for="item in xueLi"
                               :key="item.pbc_id"
                               :lable="item.attribute_name"
                               :value="item.attribute_name">
                    </el-option>
                </el-select>
            </el-form-item>
        </el-col>
        <el-col :span="5">
            <el-form-item label="教育年限" prop="jynx"> 
                <el-select v-model="human_educated_years" placeholder="请选择教育年限" v-on:change="JiaoYuNianXian()">
                    <el-option v-for="item in jiaoYuNianXian"
                               :key="item.pbc_id"
                               :lable="item.attribute_name"
                               :value="item.attribute_name">
                    </el-option>
                </el-select>
            </el-form-item>
        </el-col>
        <el-col :span="5">
            <el-form-item label="学历专业" prop="xlzy">
                <el-select v-model="human_educated_major" placeholder="请选择学历专业" v-on:change="ZhuanYe()">
                    <el-option v-for="item in zhuanYe"
                               :key="item.pbc_id"
                               :lable="item.attribute_name"
                               :value="item.attribute_name">
                    </el-option>
                </el-select>
            </el-form-item>
        </el-col>
        <el-col :span="5">
            <el-form-item label="薪酬要求" prop="xcyq">
                <el-input v-model="demand_salary_standard"></el-input>
            </el-form-item>
        </el-col>
        <el-col :span="5">
            <el-form-item label="注册时间">
                <el-input v-model="regist_time" width="20px" readonly="readonly"></el-input>
            </el-form-item>
        </el-col>
        <el-col :span="5">
            <el-form-item label="特长" prop="tc"> 
                <el-select v-model="human_specility" placeholder="请选择特长" v-on:change="TeChang()">
                    <el-option v-for="item in teChang"
                               :key="item.pbc_id"
                               :lable="item.attribute_name"
                               :value="item.attribute_name">
                    </el-option>
                </el-select>
            </el-form-item>
        </el-col>
        <el-col :span="5">
            <el-form-item label="爱好" prop="ah">
                <el-select v-model="human_hobby" placeholder="请选择爱好" v-on:change="AiHao()">
                    <el-option v-for="item in aiHao"
                               :key="item.pbc_id"
                               :lable="item.attribute_name"
                               :value="item.attribute_name">
                    </el-option>
                </el-select>
            </el-form-item>
        </el-col>
        <el-col :span="5">
            <el-form-item label="个人履历" prop="grll">
                <el-input type="textarea" v-model="human_history_records"></el-input>
            </el-form-item>
        </el-col>
        <el-col :span="5">
            <el-form-item label="备注">
                <el-input type="textarea" v-model="remark"></el-input>
            </el-form-item>
        </el-col>
    </el-form>

    <span class="anniu">
        <el-button type="primary" size="small" v-on:click="TiJiao()" :disabled = "Tj">提交</el-button>
        <el-button type="primary" size="small" v-on:click="QingChu()">清除</el-button>
    </span>
</div>

<script type="text/javascript">
    var vm = new Vue({
        el: "#app",
        data: {
            //级联属性
            //HeBingData: [],
            //cascaderProps: {
            //    value: "id",
            //    label: "name",
            //    children: "children",
            //},
            //selectedKeys: [],
            //rules: {
            //    xm: [
            //        { required: true, message: '请输入姓名!', trigger: 'blur' },
            //        { min: 2, max: 8, message: '长度在 2 到 8 个字符', trigger: 'blur' },
            //    ],
            //    sfz:[
            //        { required: true, message: '请输入身份证!', trigger: 'blur' },
            //        { min: 18, max: 20, message: '请输入18位身份证号码！', trigger: 'blur' },
            //    ],
            //    jtdh: [
            //        { required: true, message: '请输入家庭电话!', trigger: 'blur' },
            //        { pattern: /^1(3\d|4[5-9]|5[0-35-9]|6[567]|7[0-8]|8\d|9[0-35-9])\d{8}$/, message: '请输入正确的家庭电话', trigger: 'blur' },
            //    ],
            //    email:[
            //        { required: true, message: '请输入email', trigger: 'blur' },
            //        { pattern:/^([A-z0-9]{6,18})(\w|\-)[A-z0-9]+\.([A-z]{2,3})$/, message: '请输入正确的家庭电话', trigger: 'blur' },
            //    ],
            //    yb:[
            //        { required: true, message: '请输入邮编!', trigger: 'blur' },
            //        { pattern:/^[a-zA-Z0-9 ]{3,12}$/ , message: '请输入正确的邮编!', trigger: 'blur' },
            //    ],
            //    grll:[
            //        { required: true, message: '请输入个人履历!', trigger: 'blur' },
            //    ],
            //    zz:[
            //        { required: true, message: '请选择住址!', trigger: 'blur' },
            //    ],
            //    csd:[
            //        { required: true, message: '请选择出生地!', trigger: 'blur' },
            //    ],
            //    mz:[
            //        { required: true, message: '请选择民族!', trigger: 'blur' },
            //    ],
            //    zjxy:[
            //        { required: true, message: '请选择宗教信仰!', trigger: 'blur' },
            //    ],
            //    zzmm:[
            //        { required: true, message: '请选择政治面貌!', trigger: 'blur' },
            //    ],
            //    byyx:[
            //        { required: true, message: '请选择毕业院校!', trigger: 'blur' },
            //    ],
            //    xl:[
            //        { required: true, message: '请选择学历!', trigger: 'blur' },
            //    ],
            //    jynx:[
            //        { required: true, message: '请选择教育年限!', trigger: 'blur' },
            //    ],
            //    xlzy:[
            //        { required: true, message: '请选择学历专业!', trigger: 'blur' },
            //    ],
            //    xcyq:[
            //        { required: true, message: '请输入正确薪酬要求!', trigger: 'blur' },
            //        { pattern: /^[1-9][0-9]*$/, message: '请输入正确的薪酬标准!', trigger: 'blur' },
            //    ],
            //    ah:[
            //        { required: true, message: '请选择爱好!', trigger: 'blur' },
            //    ],
            //    tc:[
            //        { required: true, message: '请选择特长!', trigger: 'blur' },
            //    ]
            //},
            Tj: false,
            check_status:"",
            aiHao: [],
            teChang: [],
            zhuanYe: [],
            jiaoYuNianXian: [],
            xueLi: [],
            zhenZhiMianMao: [],
            guoJi: [],
            zongJiao: [],
            minZu: [],
            human_major_kind_id: sessionStorage.getItem("major_kind_id"),
            human_major_kind_name: sessionStorage.getItem("major_kind_name"),
            human_major_id: sessionStorage.getItem("major_id"),
            human_major_name: sessionStorage.getItem("major_name"),
            engage_type: sessionStorage.getItem("engage_type"),
            interview_status: 0,
            human_sex: "",
            human_email: "",
            human_telephone: "",
            human_homephone: "",
            human_mobilephone: "",
            human_address: [],//地址
            options1: [{
                value: '中国大陆',
                label: '中国大陆',
                children: [{
                    value: '湖南省',
                    label: '湖南省',
                    children: [{
                        value: '长沙市',
                        label: '长沙市'
                    }, {
                        value: '株洲市',
                        label: '株洲市'
                    }, {
                        value: '岳阳市',
                        label: '岳阳市'
                    }, {
                        value: '常德市',
                        label: '常德市'
                    }]
                }, {
                    value: '湖北省',
                    label: '湖北省',
                    children: [{
                        value: '武汉市',
                        label: '武汉市'
                    }, {
                        value: '孝感市',
                        label: '孝感市'
                    }, {
                        value: '宜昌市',
                        label: '宜昌市'
                    }]
                }],

            }, {
                value: '其他',
                label: '其他',
            }],
            human_postcode: "",
            human_nationality: "",
            human_birthplace: [],//出生地
            options2: [{
                value: '中国大陆',
                label: '中国大陆',
                children: [{
                    value: '湖南省',
                    label: '湖南省',
                    children: [{
                        value: '长沙市',
                        label: '长沙市'
                    }, {
                        value: '株洲市',
                        label: '株洲市'
                    }, {
                        value: '岳阳市',
                        label: '岳阳市'
                    }, {
                        value: '常德市',
                        label: '常德市'
                    }]
                }, {
                    value: '湖北省',
                    label: '湖北省',
                    children: [{
                        value: '武汉市',
                        label: '武汉市'
                    }, {
                        value: '孝感市',
                        label: '孝感市'
                    }, {
                        value: '宜昌市',
                        label: '宜昌市'
                    }]
                }],

            }, {
                value: '其他',
                label: '其他',
            }],
            human_birthday: "",
            human_race: "",
            human_religion: "",
            human_party: "",
            human_idcard: "",
            human_age: "",
            human_college: "",
            options: [{
                human_college: '长沙理工大学',
                libel: '长沙理工大学'
            }, {
                human_college: '苏州农业大学',
                libel: '苏州农业大学'
            }, {
                human_college: '家里蹲大学',
                libel: '家里蹲大学'
            }],
            human_educated_degree: "",
            human_educated_years: "",
            human_educated_major: "",
            demand_salary_standard: "",
            regist_time: "",
            human_specility: "",
            human_hobby: "",
            human_history_records: "",
            remark: "",
            human_name: "",
            //文件上传路径
            //fileList: []
            //ruleForm: {
            //    name: '',
            //},
            //rules: {
            //    name: [
            //        { required: true, message: '请输入姓名', trigger: 'blur' },
            //        { min: 3, max: 5, message: '长度在2-8个字符', trigger: 'blur' }
            //    ]
            //}
        },
        methods: {
            //文件上传
            //submitUpload() {
            //    this.$refs.upload.submit();
            //},
            //handleRemove(file, fileList) {
            //    console.log(file, fileList);
            //},
            //handlePreview(file) {
            //    console.log(file);
            //},
            //职位分类 职位名称 查询方法
            FindHeBing() {
                axios.get("/JianLiGuanLi/HeBing").then(res => {
                    this.HeBingData = res.data;
                })
            },
            //根据输入的身份证号 去计算年龄
            getAge() {
                var len = (this.human_idcard + "").length;
                if (len == 0) {
                    return 0;
                }
                else {
                    if ((len != 15) && (len != 18)) {//身份证号码只能为15位或18位其它不合法
                        return 0;
                    }
                }
                var human_birthday;
                var human_age;
                if (len == 18) {//处理18位的身份证号码从号码中得到生日和性别代码
                    human_birthday = this.human_idcard.substr(6, 4) + "-" + Number(this.human_idcard.substr(10, 2)) + "-" + Number(this.human_idcard.substr(12, 2));
                } else if (len == 15) {
                    human_birthday = "19" + this.human_idcard.substr(6, 2) + "-" + Number(this.human_idcard.substr(8, 2)) + "-" + Number(this.human_idcard.substr(10, 2));
                }
                //时间字符串里，必须是“-”而不是“/”
                var birthDate = new Date(human_birthday);
                var nowDateTime = new Date();
                human_age = nowDateTime.getFullYear() - birthDate.getFullYear();
                //计算虚岁
                //if (nowDateTime.getMonth() < birthDate.getMonth()) {
                //    human_age--;
                //} else if (nowDateTime.getMonth() == birthDate.getMonth()) {
                //    if (nowDateTime.getDate() < birthDate.getDate()) {
                //        human_age--;
                //    }
                //}
                this.human_age = human_age;
                this.human_birthday = human_birthday;
                this.getSex();
            },
            //根据输入的身份证号 去计算性别
            getSex() {
                //获取输入身份证号码
                var idCard = this.human_idcard;
                //console.info(idCard)
                //var human_sex;
                //获取出生日期
                //this.human_birthday=idCard.substr(6,10)+"-"+idCard.substr(10,12)+"-"+idCard.substr(12,14);
                //获取性别
                //console.info(1%2);
                if (idCard.substr(16, 1) % 2 != 0) {
                    human_sex = "男";
                } else {
                    human_sex = "女";
                }
                this.human_sex = human_sex;
            },
            //时间
            tick() {
                var d = new Date();
                var y = d.getFullYear();
                var moth = d.getMonth() + 1;
                var date = d.getDate();
                var h = d.getHours();
                var m = d.getMinutes();
                var s = d.getSeconds();
                var hh = 20 - 1 - h;
                var mm = 60 - 1 - m;
                var ss = 60 - s;
                if (hh > 0) {
                    mm = mm + 60 * hh;
                }
                if (moth < 10) {
                    moth = "0" + moth;
                }
                if (date < 10) {
                    date = "0" + date;
                }
                if (h < 10) {
                    h = "0" + h;
                }
                if (m < 10) {
                    m = "0" + m;
                }
                if (s < 10) {
                    s = "0" + s;
                }
                if (mm < 10) {
                    mm = "0" + mm;
                }
                if (ss < 10) {
                    ss = "0" + ss;
                }
                this.regist_time = y + " - " + moth + " - " + date + " " + h + ": " + m + ": " + s;
            },
            handleChange(val) {
                console.info("aa", val);
            },
            handleChange1(val) {
                console.info("bb", val);
            },
            //清空级联下拉框
            //clear() {
            //    this.$refs.casc.$refs.panel.clearCheckedNodes();
            //},
            //职位分类，职位名称  改变事件
            //parentCateChanged() {
            //    选中值有就大于0
            //    if (this.selectedKeys.length > 0) {
            //        获取键
            //        this.key = this.selectedKeys;
            //        console.info(this.selectedKeys);
            //        获取值
            //        this.zhi = this.$refs["casc"].getCheckedNodes()[0].pathLabels;
            //        console.info(this.$refs["casc"].getCheckedNodes()[0].pathLabels);
            //    }
            //},
            //点击提交
            TiJiao() {
                //var aa = JSON.stringify(this.human_address);
                //console.info("数据:", aa);
                axios.post("/JianLiGuanLi/Insert",
                    {
                        human_name: this.human_name,
                        engage_type: this.engage_type,
                        human_address: this.human_address[0] + this.human_address[1] + this.human_address[2],
                        human_postcode: this.human_postcode,
                        //human_major_kind_id: this.key[0],
                        //human_major_kind_name: this.zhi[0],
                        //human_major_id: this.key[1],
                        //human_major_name: this.zhi[1],
                        human_major_kind_id: this.human_major_kind_id,
                        human_major_kind_name: this.human_major_kind_name,
                        human_major_id: this.human_major_id,
                        interview_status: this.interview_status,//状态
                        human_major_name: this.human_major_name,
                        human_telephone: this.human_telephone,
                        human_homephone: this.human_homephone,
                        human_mobilephone: this.human_mobilephone,
                        human_email: this.human_email,
                        human_hobby: this.human_hobby,
                        human_specility: this.human_specility,
                        human_sex: this.human_sex,
                        human_religion: this.human_religion,
                        human_party: this.human_party,
                        human_nationality: this.human_nationality,
                        human_race: this.human_race,
                        human_birthday: this.human_birthday,
                        human_age: this.human_age,
                        human_educated_degree: this.human_educated_degree,
                        human_educated_years: this.human_educated_years,
                        human_educated_major: this.human_educated_major,
                        human_college: this.human_college,
                        human_idcard: this.human_idcard,
                        human_birthplace: this.human_birthplace[0] + this.human_birthplace[1] + this.human_birthplace[2],
                        demand_salary_standard: this.demand_salary_standard,
                        human_history_records: this.human_history_records,
                        remark: this.remark,
                        regist_time: this.regist_time,
                        check_status:1
                    }).then(res => {
                        if (res.data > 0) {
                            alert("添加成功");
                            this.Tj = true;
                            this.QingChu();
                        }
                    })
            },
            AiHao() {
                axios.get("/JianLiGuanLi/AiHao").then(res => {
                    this.aiHao = res.data;
                })
            },
            TeChang() {
                axios.get("/JianLiGuanLi/TeChang").then(res => {
                    this.teChang = res.data;
                })
            },
            ZhuanYe() {
                axios.get("/JianLiGuanLi/ZhuanYe").then(res => {
                    this.zhuanYe = res.data;
                })
            },
            JiaoYuNianXian() {
                axios.get("/JianLiGuanLi/JiaoYuNianXian").then(res => {
                    this.jiaoYuNianXian = res.data;
                })
            },
            XueLi() {
                axios.get("/JianLiGuanLi/XueLi").then(res => {
                    this.xueLi = res.data;
                })
            },
            ZhenZhiMianMao() {
                axios.get("/JianLiGuanLi/ZhengZhiMianMao").then(res => {
                    this.zhenZhiMianMao = res.data;
                })
            },
            GuoJi() {
                axios.get("/JianLiGuanLi/GuoJi").then(res => {
                    this.guoJi = res.data;
                })
            },
            ZongJiao() {
                axios.get("/JianLiGuanLi/ZongJiao").then(res => {
                    this.zongJiao = res.data;
                })
            },
            MinZu() {
                axios.get("/JianLiGuanLi/MinZu").then(res => {
                    this.minZu = res.data;
                })
            },
            //清空文本框
            QingKong() {
                //this.human_major_kind_name = "";
                //this.human_major_name = "";
                this.engage_type = "";
                this.human_sex = "";
                this.human_email = "";
                this.human_telephone = "";
                this.human_homephone = "";
                this.human_mobilephone = "";
                this.human_address = "";
                this.human_postcode = "";
                this.human_nationality = "";
                this.human_birthplace = "";
                this.human_birthday = "";
                this.human_race = "";
                this.human_religion = "";
                this.human_party = "";
                this.human_idcard = "";
                this.human_age = "";
                this.human_college = "";//毕业院校
                this.human_educated_degree = "";
                this.human_educated_years = "";
                this.human_educated_major = "";
                this.demand_salary_standard = "";
                this.regist_time = "";
                this.human_specility = "";
                this.human_hobby = "";
                this.human_history_records = "";
                this.remark = "";
                this.human_name = "";
            },
            //清除按钮
            QingChu() {
                //this.clear();
                this.QingKong();
            },
        },
        mounted() {
            this.AiHao();
            this.TeChang();
            this.ZhuanYe();
            this.JiaoYuNianXian();
            this.XueLi();
            this.ZhenZhiMianMao();
            this.GuoJi();
            this.ZongJiao();
            this.MinZu();
            this.FindHeBing();
            window.onload = this.tick;
            var out = window.setInterval(this.tick, 1000);
        },
    })
</script>
<style scoped>
    .el-descriptions-item__label.is-bordered-label {
        background: white;
        color: black;
    }

    .el-descriptions :not(.is-bordered) .el-descriptions-item__cell {
        padding-bottom: 8px;
    }

    .anniu {
        position: fixed;
        top: 700px;
        left: 874px;
    }
</style>
